home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 1 / Cream of the Crop 1.iso / PROGRAM / MISCPAS.ARJ / TICKTOCK.PAS < prev    next >
Pascal/Delphi Source File  |  1992-06-23  |  3KB  |  76 lines

  1. PROGRAM ticktock(input,output);
  2. {
  3.        Name: ticktock.pas
  4.      Author: Michael Tighe
  5.      System: IBM PC/XT/AT/PS2, MS-DOS 3.30
  6.    Language: Turbo Pascal Version 5.0
  7. Description: Demo of IBM PC's high resolution clock
  8.  
  9.     INFO FOR TICKTOCK:
  10.  
  11.     The TICKTOCK programs demonstrate how to obtain accurate timing
  12. information from the IBM PC/XT/AT family of computers. The next few
  13. paragraphs should give you a basic idea of how the time is stored in these
  14. computer systems.
  15.  
  16.     In the PC family, an internal clock runs at 1.193180 Mhz. This clock
  17. is divided by 65536 to give 18.206482 clock pulses per second (.0549255
  18. seconds per clock pulse). Therefore, the clock 'ticks' every .0549255
  19. seconds.
  20.  
  21.     Two addresses in low memory are used to keep track of the tick count.
  22. They are both 1 word (two bytes) in length. The first is at address
  23. 0000:046C. It is incremented 18.2 times a second. When it overflows, it is
  24. reset to 0 and another word at address 0000:046E is incremented.
  25.  
  26.     It should be noted that the word at address 0000:046E is also the
  27. current hour, in 24 hour format. The address at 0000:046C when divided by
  28. 18.2, is the current time past the hour, in seconds.
  29.  
  30. }
  31. { compiler directives }
  32. {$a+}               {word alignment         (+=on,-=off                  (+)}
  33. {$b+}               {boolean evaluation     (+=complete,-=short circuit) (-)}
  34. {$d-}               {debug information      (+=on,-=off)                 (+)}
  35. {$e-}               {emulation              (+=on,-=off)                 (+)}
  36. {$f-}               {force far calls        (+=all far,-=as needed)      (-)}
  37. {$i-}               {i/o error checking     (+=on,-=off)                 (+)}
  38. {$l-}               {local symbols          (+=on,-=off)                 (+)}
  39. {$m 16384,0,655360} {memory allocation      (stk,minhp,maxhp)   (16k,0,640k)}
  40. {$n+}               {numeric data processor (+=true,-=false              (-)}
  41. {$o-}               {overlays               (+=on,-=off                  (+)}
  42. {$r-}               {range checking         (+=on,-=off                  (+)}
  43. {$s-}               {stack checking         (+=on,-=off                  (+)}
  44. {$v-}               {var string checking    (+=on,-=off)                 (+)}
  45.  
  46. USES
  47. crt;
  48.  
  49. CONST
  50. version_number = '[TICKTOCK Version 87.365]';
  51.  
  52. VAR
  53. t1,t2     : byte;
  54. tick,tock : real;
  55.  
  56. BEGIN
  57.    writeln(version_number); writeln;
  58.  
  59.    t1 := 0; t2 := 0;
  60.    t1 := mem[$0000:$046c]; t2 := mem[$0000:$046d];
  61.    tick := int(t1) + int(t2)*256;
  62.    t1 := mem[$0000:$046e]; t2 := mem[$0000:$046f];
  63.    tock := int(t1) + int(t2)*256;
  64.    writeln('Tick value is ',tick:6:0,', Tock value is ',tock:6:0);
  65.  
  66.    writeln('Sleeping for 5 seconds (~91 ticks)...');
  67.    delay(5000);
  68.  
  69.    t1 := 0; t2 := 0;
  70.    t1 := mem[$0000:$046c]; t2 := mem[$0000:$046d];
  71.    tick := int(t1) + int(t2)*256;
  72.    t1 := mem[$0000:$046e]; t2 := mem[$0000:$046f];
  73.    tock := int(t1) + int(t2)*256;
  74.    writeln('Tick value is ',tick:6:0,', Tock value is ',tock:6:0);
  75. END.
  76.